class HouseTtem:
    def __init__(self,name,area):
        self.name=name
        self.area=area
    def __str__(self):
        return f'家具名字{self.name}占地面积{self.area}' #格式化输出家具
class House:
    def __init__(self,type,total_area):
        self.type=type
        self.total_area=total_area
        self.free_area=total_area
        self.item_list=[]
    def add_itme(self,itme):
        if  self.free_area>=itme.area:
            self.item_list.append(itme.name)
            self.free_area=self.free_area-itme.area
        else:
            print('不能存放')
    def __str__(self):
        return f'户型:{self.type}' \
               f'丶总面积{self.total_area}' \
               f'丶剩余面积:{self.free_area}' \
               f'丶家具名称列表:{self.item_list}'

if __name__=='__main__':
    # 实例化对象
    bed = HouseTtem(name='席梦思',area=4)
    chest=HouseTtem(name='衣柜',area=2)
    table=HouseTtem(name='餐桌',area=100)
    print(bed,chest,table)  #输入几个就格式化输出几个

    home=House(type='别墅',total_area=300,)
    # print(home)  #没有放进东西
    # home.add_itme(bed)
    # home.add_itme(table)  #放进三样东西
    # home.add_itme(chest)
    # print(home)

    home.add_itme(bed)
    home.add_itme(table)  #放进三样东西
    home.add_itme(chest)
    print(home)